package com.smart.community.region.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.smart.community.commons.result.PageResult;
import com.smart.community.region.dto.ShopLeaseContractDTO;
import com.smart.community.region.entity.ShopLeaseContract;
import com.smart.community.region.vo.ShopLeaseContractVO;

import java.time.LocalDate;
import java.util.List;

/**
 * 店铺租赁合同Service接口
 * 
 * @author Wu.Liang
 * @version 1.0.0
 * @since 2025-01-30
 */
public interface IShopLeaseContractService extends IService<ShopLeaseContract> {
    
    /**
     * 分页查询租赁合同
     * 
     * @param current 当前页
     * @param size 每页大小
     * @param shopId 店铺ID
     * @param contractStatus 合同状态
     * @return 分页结果
     * @throws Exception 异常
     */
    PageResult<ShopLeaseContractVO> getContractPage(Integer current, Integer size, Long shopId, Integer contractStatus) throws Exception;
    
    /**
     * 根据ID获取租赁合同详情
     * 
     * @param id 合同ID
     * @return 租赁合同详情
     * @throws Exception 异常
     */
    ShopLeaseContractVO getContractById(Long id) throws Exception;
    
    /**
     * 根据店铺ID查询租赁合同列表
     * 
     * @param shopId 店铺ID
     * @return 租赁合同列表
     * @throws Exception 异常
     */
    List<ShopLeaseContractVO> getContractsByShopId(Long shopId) throws Exception;
    
    /**
     * 创建租赁合同
     * 
     * @param contractDTO 租赁合同DTO
     * @return 合同ID
     * @throws Exception 异常
     */
    Long createContract(ShopLeaseContractDTO contractDTO) throws Exception;
    
    /**
     * 更新租赁合同
     * 
     * @param contractDTO 租赁合同DTO
     * @return 是否成功
     * @throws Exception 异常
     */
    Boolean updateContract(ShopLeaseContractDTO contractDTO) throws Exception;
    
    /**
     * 删除租赁合同
     * 
     * @param id 合同ID
     * @return 是否成功
     * @throws Exception 异常
     */
    Boolean deleteContract(Long id) throws Exception;
    
    /**
     * 生成月度租金记录
     * 
     * @param contractId 合同ID
     * @param startMonth 开始月份(YYYY-MM)
     * @param endMonth 结束月份(YYYY-MM)
     * @return 生成的记录数量
     * @throws Exception 异常
     */
    Integer generateMonthlyRentRecords(Long contractId, String startMonth, String endMonth) throws Exception;
    
    /**
     * 检查合同时间冲突
     * 
     * @param shopId 店铺ID
     * @param startDate 开始日期
     * @param endDate 结束日期
     * @param excludeId 排除的合同ID
     * @return 是否存在冲突
     * @throws Exception 异常
     */
    Boolean checkDateConflict(Long shopId, LocalDate startDate, LocalDate endDate, Long excludeId) throws Exception;
}
